package edu.lfsfxy.controller;

import edu.lfsfxy.entity.Meetingroom;
import edu.lfsfxy.mapping.MeetingroomMapper;
import io.swagger.annotations.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 王希辰
 */
@Controller
@Api(tags = "会议室11")
public class MeetingRoomController {
    @Resource
    MeetingroomMapper meetingroomMapper;

    @GetMapping("meetingroom/{id}")
    @ResponseBody
    @ApiOperation(value = "查询会议室", notes = "id不能为空")
    @ApiImplicitParam(name = "id", value = "会议室id", required = true,dataType = "Integer",paramType = "path")
    @ApiResponses({
            @ApiResponse(code=400, message="请求参数没填好"),
            @ApiResponse(code=404, message="请求路径没有或页面跳转路径不对")
    })
    public Meetingroom find(@PathVariable Integer id) {
        return meetingroomMapper.selectByPrimaryKey(id);
    }

    @ApiOperation(value = "删除会议室", notes = "id不能为空")
    @DeleteMapping("meetingroom/{id}")
    @ResponseBody
    @ApiImplicitParam(name = "id", value = "会议室id", required = true,dataType = "Integer",paramType = "path")
    public Integer delete(@PathVariable Integer id) {
        return meetingroomMapper.deleteByPrimaryKey(id);
    }

    @ApiOperation(value = "添加会议室", notes = "id不能为空")
    @PostMapping("meetingroom")
    @ResponseBody
    @ApiImplicitParam(name = "meetingroom",value = "会议室信息",dataType = "Meetingroom",paramType = "form")
    public Integer insert(@RequestBody Meetingroom meetingroom) {
        return meetingroomMapper.insertSelective(meetingroom);
    }

    @ApiOperation(value = "更新会议室", notes = "id不能为空")
    @PutMapping("meetingroom")
    @ResponseBody
    @ApiImplicitParam(name = "meetingroom",value = "会议室信息",dataType = "Meetingroom",paramType = "form")
    public Integer update(@RequestBody Meetingroom meetingroom) {
        return meetingroomMapper.updateByPrimaryKeySelective(meetingroom);
    }
}
